package org.kordakus.shoot.gui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.net.URL;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JComponent;

public final class ShootGuiUtils
{

	private ShootGuiUtils()
	{
	}

	// FRAME
	public static final int			WINDOW_HEIGH					= 650;
	public static final int			WINDOW_WIDTH					= 500;

	// TABLE
	public static final int			TABLE_FILENAME_INDEX			= 0;
	public static final int			TABLE_CAMERAMAKE_INDEX			= 1;
	public static final int			TABLE_CAMERAMODEL_INDEX			= 2;
	public static final int			TABLE_DATETIMEORIGINAL_INDEX	= 3;
	public static final int			TABLE_NEWDATETIMEORIGINAL_INDEX	= 4;

	// IMAGES
	public static final Icon		IMAGE_ADD_FILE					= getImage("/image/picture_add.png");
	public static final Icon		IMAGE_REMOVE_FILE				= getImage("/image/picture_delete.png");

	// Colors
	public static final Color		COLOR_TABLE_ROW_EVEN			= new Color(250, 250, 250);
	public static final Color		COLOR_TABLE_ROW_EVEN_SELECTED	= new Color(98, 134, 183);
	public static final Color		COLOR_TABLE_ROW_ODD				= Color.WHITE;
	public static final Color		COLOR_TABLE_ROW_ODD_SELECTED	= new Color(112, 146, 190);

	// Fonts
	public static final Font		FONT_FORM						= new Font("Tahoma", Font.PLAIN, 11);

	// Dimension
	public static final Dimension	DIMENSION_BUTTON_SIZE			= new Dimension(120, 22);

	public static Icon getImage(final String path)
	{
		URL url = ShootGuiUtils.class.getResource(path);
		if (url != null)
		{
			return new ImageIcon(url);
		} else
		{
			return null;
		}
	}

	public static void setBackgroundColor(JComponent component, int row, boolean selected)
	{
		if (component != null)
		{
			if (selected)
			{
				component.setForeground(Color.WHITE);
				if (row % 2 == 0)
				{
					component.setBackground(COLOR_TABLE_ROW_EVEN_SELECTED);
				} else
				{
					component.setBackground(COLOR_TABLE_ROW_ODD_SELECTED);
				}
			} else
			{
				component.setForeground(Color.DARK_GRAY);
				if (row % 2 == 0)
				{
					component.setBackground(COLOR_TABLE_ROW_EVEN);
				} else
				{
					component.setBackground(COLOR_TABLE_ROW_ODD);
				}
			}
		}
	}

}
